ig.module( 
	'game.gameTypes.gameWordSearch' 
)
.requires(
	'impact.game',
	'game.gameTypes.gameBase',
	'game.entities.base.word',
	'game.entities.base.dictionary'
)
.defines(function()
{
    GameWordSearch = GameBase.extend(
    {
	font: new ig.Font( 'media/fonts/arialRounded.png' ),
	
        init: function()
        {
	    this.parent();
	    this.defaultValues();
        },
        
	defaultValues: function()
	{
	    ig.global.numberOfPicks = 0
	    ig.global.failed = false;
	    
	    ig.global.failed = false;
	    ig.global.paused = false;

	    ig.global.c = -1;
	    ig.global.l = -1;
	    ig.global.t = 0;
	    
	    ig.global.dictionary = new Dictionary();
	    ig.global.dictionary.build();	
	},
	
	postInit: function()
	{
	    ig.global.validPicks = 0;//ig.global.dictionary.words.length;
	    for (var i = 0; i < ig.global.dictionary.words.length; ++i)
	    {
		ig.global.validPicks += ig.global.dictionary.words[i].word.length;
	    }
	},
	
        update: function()
        {
	    this.parent();
	    
	    ig.global.dictionary.update();	    
        },
        
	pausedUpdate: function()
	{
	    if (ig.input.state('enter'))
	    {
		this.defaultValues();		
		this.game.loadLevelDeferred(LevelPickInside);
	    }
	},
	
        draw: function()
        {
	    this.parent();
	    this.font.draw( 'Letras: ' + ig.global.validPicks, 490, 445, ig.Font.ALIGN.LEFT );
	    
	    this.font.draw( 'T: ' + ig.global.t, 490, 385, ig.Font.ALIGN.LEFT );	    
	    this.font.draw( 'C: ' + ig.global.c, 490, 425, ig.Font.ALIGN.LEFT );
	    this.font.draw( 'L: ' + ig.global.l, 490, 405, ig.Font.ALIGN.LEFT );
	    
	    if (ig.global.numberOfPicks == ig.global.validPicks)
	    {
		this.font.draw( 'Parabens !!!', 190, 20, ig.Font.ALIGN.LEFT );	
		this.font.draw( 'Pressione enter.', 190, 68, ig.Font.ALIGN.LEFT );
		ig.global.paused = true;
	    }
	    else if (ig.global.failed == true)
	    {
		this.font.draw( 'Ops... voce quase acertou...', 190, 20, ig.Font.ALIGN.LEFT );
		this.font.draw( 'Para tentar novamente pressione enter.', 190, 36, ig.Font.ALIGN.LEFT );		
		ig.global.paused = true;				
	    }
	    else
	    {
	    }

	    ig.global.dictionary.draw();
        }       
    });
});